package com.itheima.job;

import java.util.Scanner;

public class Test04 {
    public static void main(String[] args)  {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入用户名：");
        String name = sc.nextLine();

        System.out.println("请输入密码：");
        String password = sc.nextLine();

        try {
            login(name, password);
        }catch (LoginException l){
            l.printStackTrace();
        }

//        if (!("admin".equals(name))){
//            try {
//                throw new LoginException("用户名不存在");
//            } catch (LoginException e) {
//                e.printStackTrace();
//            }
//
//        }else if (!("admin".equals(password))){
//            try {
//                throw new LoginException("密码错误");
//            } catch (LoginException e) {
//                e.printStackTrace();
//            }
//        }else {
//            System.out.println("欢迎xxx");
//        }



    }

    private static void login(String name, String password) throws LoginException {
        if (!("admin".equals(name))){
            throw new LoginException("用户名不存在");
        }else if (!("admin".equals(password))){
            throw new LoginException("密码错误");
        }else {
            System.out.println("欢迎xxx");
        }

    }
}
class LoginException extends Exception  {
    public LoginException() {
    }

    public LoginException(String message) {
        super(message);
    }

}


